package com.pengweiwei.androidzygote.main.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.core.app.ActivityCompat;

import com.pengweiwei.androidzygote.R;
import com.pengweiwei.androidzygote.functions.httprequest.HttpDemoIndexActivity;
import com.pengweiwei.androidzygote.functions.imagetransform.ImageTransformActivity;
import com.pengweiwei.androidzygote.functions.media.AudioPlayActivity;
import com.pengweiwei.androidzygote.functions.picture.PictureBrowDemoActivity;
import com.pengweiwei.androidzygote.goods.GoodsListActivity;
import com.putong35.common.baseactfrag.fragment.BaseFragment;
import com.putong35.common.baseactfrag.view.CenterToolbar;
import com.putong35.easyui.picture.picker.GetAudioAndUploadFragment;
import com.putong35.easyui.picture.picker.GetVideoAndUploadFragment;

import butterknife.OnClick;


public class BaseFunctionIndexFragment extends BaseFragment implements ActivityCompat.OnRequestPermissionsResultCallback {
    public static final String TAG = BaseFunctionIndexFragment.class.getSimpleName();

    GetVideoAndUploadFragment getVideoAndUploadFragment;
    GetAudioAndUploadFragment getAudioAndUploadFragment;

    @OnClick(R.id.btnHttpDemo)
    public void onBtnHttpDemoClicked() {
        HttpDemoIndexActivity.start(getContext());
    }


    @OnClick(R.id.btnBrowsePicture)
    public void onBtnBrowsePictureClicked() {
        Intent intent = new Intent(getActivity(), PictureBrowDemoActivity.class);
        startActivity(intent);
    }


    @OnClick(R.id.btnImageTransform)
    public void onBtnImageTransformClicked() {
        Intent intent = new Intent(getActivity(), ImageTransformActivity.class);
        startActivity(intent);
    }


    @OnClick(R.id.btnMediaPlayerAudio)
    public void btnMediaPlayerAudio() {
        AudioPlayActivity.start(getActivity());
    }

    @OnClick(R.id.btnChooseVideo)
    public void btnChooseVideo() {
        getVideoAndUploadFragment.getVedio();
    }

    @OnClick(R.id.btnChooseRadio)
    public void btnChooseRadio() {
//        getAudioAndUploadFragment.getVedio();
        Intent intent = new Intent(getActivity(), GoodsListActivity.class);
        startActivity(intent);

    }


    public BaseFunctionIndexFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment ThemeAttrFragment.
     */
    public static BaseFunctionIndexFragment newInstance(String param1, String param2) {
        BaseFunctionIndexFragment fragment = new BaseFunctionIndexFragment();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
        }

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);

        getVideoAndUploadFragment = new GetVideoAndUploadFragment();
        getChildFragmentManager().beginTransaction().add(getVideoAndUploadFragment, "getVideoAndUploadFragment").commit();

        getAudioAndUploadFragment = new GetAudioAndUploadFragment();
        getChildFragmentManager().beginTransaction().add(getAudioAndUploadFragment, "getAudioAndUploadFragment").commit();

        return view;
    }

    @Override
    public View createDataView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_base_function_index, container, false);
        CenterToolbar toolbar = view.findViewById(R.id.toolbar);
        toolbar.setTitle("基础功能");
        return view;
    }

}
